<?php get_main_menu("production") ?>
<?php 
mysql_select_db($database_drycleaners_conn, $drycleaners_conn);
$query_get_suborder = "SELECT
       branch.name as branch_from,
       suborder.suborder_no,
       suborder.branch_to_id,
	   suborder.id,
	   suborder.received_date,
	   suborder.returned_date,
	   suborder.returned,
	   suborder.receive_returned,
	   suborder.receive_returned_date,
	   suborder.received,
	   suborder.created_date,
       branch_2.name as branch_to
  FROM    (   (   drycleaners.suborder suborder
               INNER JOIN
                  drycleaners.branch branch_2
               ON (suborder.branch_to_id = branch_2.id))
           INNER JOIN
              drycleaners.branch branch
           ON (suborder.branch_from_id = branch.id))
		  Where branch_from_id='".$_SESSION['branch_id']."'
		  AND suborder.received_date!='00-00-00 00:00:00'
		  AND suborder.received='true'
		  AND suborder.returned_date='00-00-00 00:00:00'
		  AND suborder.record_status='active'
		  ";
$get_suborder = mysql_query($query_get_suborder, $drycleaners_conn) or die(mysql_error());
$row_get_suborder = mysql_fetch_assoc($get_suborder);
$totalRows_get_suborder = mysql_num_rows($get_suborder);
?>
<?php include"includes/table_settings.php"?>
  <?php
 if($_REQUEST['suborder_returned']==true && $_REQUEST['suborder_id']!=""){
 
 $query_remove_record="update suborder set returned='true', returned_by='".$loggedin_id."',  returned_date='".date("y-m-d H:i:s")."' where suborder.id='".$_REQUEST["suborder_id"]."'";
 mysql_query($query_remove_record,$drycleaners_conn) or die(mysql_error());
 if(mysql_affected_rows($drycleaners_conn)>0){
	 alert_redirect_drycleaners("production_suborder_return_view","2",$_REQUEST["id"]);
	 }
 }
?>  
  <div>
  <a href=".?<?php echo $_REQUEST['back_page']?>"><img src="images/back-button.png" width="30" height="30" title="Back" /></a></div>
  <div class="module_title"><strong>Returns To Reception</strong></div>
  
              <table cellpadding="0" cellspacing="0" bsuborder="0" id="dataTable">
                <thead>
                  <tr>
                    <th>Id</th>
                    <th>suborder No</th>
                    <th>Branch From</th>
                    <th>Received Date</th>
                    <th></th>
                    <th></th>
                  </tr>
                </thead>
                <tbody>
                <!--Loop start, you could use a repeat region here-->
  <?php 
  if($totalRows_get_suborder >0 )
  do{
	  
	  ?>
    <!--Loop start, you could use a repeat region here-->
    <tr>
      <td><?php echo $row_get_suborder['id']?></td>
      <td><?php echo $row_get_suborder['suborder_no']?></td>
      <td><?php echo $row_get_suborder['branch_from']?></td>
      <td><?php echo date("d-M-Y H:i:s",strtotime($row_get_suborder['received_date']))?></td>
      <td><a href=".?<?php get_child_link("0000-00-00 00:00:00","production_suborder_item_view","production_suborder_item_view");?>= true&amp;suborder_id=<?php echo $row_get_suborder['id']; ?>&order_id=<?php echo $_REQUEST['order_id']; ?>&back_page=production_suborder_returned_view"><input name='' value='Items' type='button' id='edit_forms'/></a></td>
      <td>
    <?php if($row_get_suborder['returned_date']=='0000-00-00 00:00:00' && $row_get_suborder['returned']!='true' && $row_get_suborder['returned']!='false') {?>
      <a href="?suborder_returned_view&suborder_id=<?php echo $row_get_suborder['id']; ?>&suborder_returned=true"><input name='' value='Receive' type='button' id='edit_forms'/></a>
      <?php }?>
      </td>
    </tr>
    <?php }while($row_get_suborder=mysql_fetch_assoc($get_suborder));?>
                  <!--Loop end-->
                </tbody>
              </table>
<?php
mysql_free_result($get_suborder);
?>